package sudroid.json;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

public class JSONTokener
{
  private int index;
  private char lastChar;
  private Reader reader;
  private boolean useLastChar;

  public JSONTokener(Reader paramReader)
  {
    if (paramReader.markSupported());
    for (Object localObject = paramReader; ; localObject = new BufferedReader(paramReader))
    {
      this.reader = ((Reader)localObject);
      this.useLastChar = 0;
      this.index = 0;
      return;
    }
  }

  public JSONTokener(String paramString)
  {
    this(localStringReader);
  }

  public static int dehexchar(char paramChar)
  {
    int i;
    if ((paramChar >= '0') && (paramChar <= '9'))
      i = paramChar - '0';
    while (true)
    {
      return i;
      if ((paramChar >= 'A') && (paramChar <= 'F'))
      {
        i = paramChar - '7';
        continue;
      }
      if ((paramChar >= 'a') && (paramChar <= 'f'))
      {
        i = paramChar - 'W';
        continue;
      }
      i = -1;
    }
  }

  public void back()
    throws JSONException
  {
    if ((this.useLastChar) || (this.index <= 0))
      throw new JSONException("Stepping back two steps is not supported");
    int i = this.index - 1;
    this.index = i;
    this.useLastChar = 1;
  }

  public boolean more()
    throws JSONException
  {
    if (next() == 0);
    for (int i = 0; ; i = 1)
    {
      return i;
      back();
    }
  }

  public char next()
    throws JSONException
  {
    if (this.useLastChar)
    {
      this.useLastChar = 0;
      if (this.lastChar != 0)
      {
        int i = this.index + 1;
        this.index = i;
      }
    }
    for (int j = this.lastChar; ; j = this.lastChar)
    {
      int m;
      while (true)
      {
        return j;
        try
        {
          int k = this.reader.read();
          m = k;
          if (m > 0)
            break;
          this.lastChar = 0;
          j = 0;
        }
        catch (IOException localIOException)
        {
          throw new JSONException(localIOException);
        }
      }
      int n = this.index + 1;
      this.index = n;
      char c = (char)m;
      this.lastChar = c;
    }
  }

  public char next(char paramChar)
    throws JSONException
  {
    char c = next();
    if (c != paramChar)
    {
      String str = "Expected '" + paramChar + "' and instead saw '" + c + "'";
      throw syntaxError(str);
    }
    return c;
  }

  public String next(int paramInt)
    throws JSONException
  {
    if (paramInt == 0);
    char[] arrayOfChar;
    for (String str = ""; ; str = new String(arrayOfChar))
    {
      return str;
      arrayOfChar = new char[paramInt];
      int i = 0;
      if (this.useLastChar)
      {
        this.useLastChar = 0;
        int j = this.lastChar;
        arrayOfChar[0] = j;
        i = 1;
      }
      while (true)
      {
        if (i < paramInt);
        try
        {
          Reader localReader = this.reader;
          int k = paramInt - i;
          int m = localReader.read(arrayOfChar, i, k);
          int n = m;
          if (n == -1)
          {
            int i1 = this.index + i;
            this.index = i1;
            if (i >= paramInt)
              break;
            throw syntaxError("Substring bounds error");
          }
          else
          {
            i += n;
          }
        }
        catch (IOException localIOException)
        {
          throw new JSONException(localIOException);
        }
      }
      int i2 = paramInt - 1;
      char c = arrayOfChar[i2];
      this.lastChar = c;
    }
  }

  public char nextClean()
    throws JSONException
  {
    int i;
    do
      i = next();
    while ((i != 0) && (i <= 32));
    return i;
  }

  public String nextString(char paramChar)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    while (true)
    {
      char c1 = next();
      switch (c1)
      {
      default:
        if (c1 != paramChar)
          break;
        return localStringBuffer1.toString();
      case '\000':
      case '\n':
      case '\r':
        throw syntaxError("Unterminated string");
      case '\\':
        c1 = next();
        switch (c1)
        {
        default:
          StringBuffer localStringBuffer2 = localStringBuffer1.append(c1);
          break;
        case 'b':
          StringBuffer localStringBuffer3 = localStringBuffer1.append(8);
          break;
        case 't':
          StringBuffer localStringBuffer4 = localStringBuffer1.append(9);
          break;
        case 'n':
          StringBuffer localStringBuffer5 = localStringBuffer1.append(10);
          break;
        case 'f':
          StringBuffer localStringBuffer6 = localStringBuffer1.append(12);
          break;
        case 'r':
          StringBuffer localStringBuffer7 = localStringBuffer1.append(13);
          break;
        case 'u':
          char c2 = (char)Integer.parseInt(next(4), 16);
          StringBuffer localStringBuffer8 = localStringBuffer1.append(c2);
          break;
        case 'x':
          char c3 = (char)Integer.parseInt(next(2), 16);
          StringBuffer localStringBuffer9 = localStringBuffer1.append(c3);
        }
        break;
      }
      StringBuffer localStringBuffer10 = localStringBuffer1.append(c1);
    }
  }

  public String nextTo(char paramChar)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    while (true)
    {
      char c = next();
      if ((c == paramChar) || (c == 0) || (c == 10) || (c == 13))
      {
        if (c != 0)
          back();
        return localStringBuffer1.toString().trim();
      }
      StringBuffer localStringBuffer2 = localStringBuffer1.append(c);
    }
  }

  public String nextTo(String paramString)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    while (true)
    {
      int i = next();
      if ((paramString.indexOf(i) >= 0) || (i == 0) || (i == 10) || (i == 13))
      {
        if (i != 0)
          back();
        return localStringBuffer1.toString().trim();
      }
      StringBuffer localStringBuffer2 = localStringBuffer1.append(i);
    }
  }

  public Object nextValue()
    throws JSONException
  {
    int i = nextClean();
    StringBuffer localStringBuffer1;
    String str;
    Object localObject;
    switch (i)
    {
    default:
      localStringBuffer1 = new StringBuffer();
      if ((i >= 32) && (",:]}/\\\"[{;=#".indexOf(i) < 0))
        break;
      back();
      str = localStringBuffer1.toString().trim();
      if (str.equals(""))
        throw syntaxError("Missing value");
    case 34:
    case 39:
      localObject = nextString(i);
    case 123:
    case 40:
    case 91:
    }
    while (true)
    {
      return localObject;
      back();
      localObject = new JSONObject(this);
      continue;
      back();
      localObject = new JSONArray(this);
      continue;
      StringBuffer localStringBuffer2 = localStringBuffer1.append(i);
      int j = next();
      break;
      localObject = JSONObject.stringToValue(str);
    }
  }

  public char skipTo(char paramChar)
    throws JSONException
  {
    try
    {
      int i = this.index;
      this.reader.mark(2147483647);
      char c = next();
      if (c == 0)
      {
        this.reader.reset();
        this.index = i;
      }
      while (true)
      {
        return c;
        if (c != paramChar)
          break;
        back();
      }
    }
    catch (IOException localIOException)
    {
    }
    throw new JSONException(localIOException);
  }

  public JSONException syntaxError(String paramString)
  {
    String str1 = String.valueOf(paramString);
    StringBuilder localStringBuilder = new StringBuilder(str1);
    String str2 = toString();
    String str3 = str2;
    return new JSONException(str3);
  }

  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder(" at character ");
    int i = this.index;
    return i;
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.json.JSONTokener
 * JD-Core Version:    0.6.0
 */